//index.js
//获取应用实例
var app = getApp()
var common = require('../module/common.js');
var page = {
  data: {
    motto: 'Hello World',
    userInfo: {},
    btnText:"按钮111",
    avatarShow:true,
    item:[1,2,3],
    array: [{msg: '1'}, {msg: '2'}],
    imageUrl:null
  },
  onLoad: function(options) {
    // Do some initialize when page load.
  },
  onReady: function() {
    // Do something when page ready.
  },
  onShow: function() {
    // Do something when page show.
  },
  onHide: function() {
    // Do something when page hide.
  },
  onUnload: function() {
    // Do something when page close.
  },
  onPullDownRefresh: function() {
    // Do something when pull down.
  },
  onReachBottom: function() {
    // Do something when page reach bottom.
  },
  onShareAppMessage: function () {
   // return custom share data when user share.
  },
  // Event Handler
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  //绑定按钮点击事件
  btnClick:function(){
    console.log("这是点击事件");
    //this.setData({avatarShow:!this.data.avatarShow})
    var page = this;
    wx.chooseImage({
    count: 1, // 默认9
    sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
    sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
    success: function (res) {
      // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
      var tempFilePaths = res.tempFilePaths
      console.log(tempFilePaths);
      page.setData({imageUrl:tempFilePaths})
    }
  })
  },
  hello:function(){
    common.sayHello("jun");
  },
  onLoad: function () {
    console.log('onLoad')
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
    })
  }
}


Page(page)
